<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>页面公共</title>
    <!--公共css-->
    <div id="com_css">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="author" content="ZhangHeng">
        <link href="static/favicon.ico" rel="shortcut icon" type="image/x-icon"/>
        <!--        <link rel="shortcut icon" href="#" type="image/png">-->

        <link href="static/css/style.css" rel="stylesheet">
        <!--        <link href="/static/css/style-responsive.css" rel="stylesheet">-->
        <!--        <link href="/static/css/bootstrap.min.css" rel="stylesheet">-->
        <!--        <link href="/static/css/load.css" rel="stylesheet">-->
        <!--        <link href="/static/css/bootstrap-reset.css" rel="stylesheet">-->
        <script src="static/js/localFile.js" th:version="${version}"></script>
        <script>
            eval(loadJs("static/js/client-info.js"));
            // eval(loadCss("/static/css/style.css"));
            loadCss("static/css/style-responsive.css");
            loadCss("static/css/bootstrap.min.css");
            loadCss("static/css/bootstrap-reset.css");
            loadCss("static/css/load.css");
            eval(loadJs("static/js/jquery-1.10.2.min.js"));
        </script>
    </div>
    <!--公共js-->
    <div id="com_js">
        <!--        <script src="/static/js/jquery-1.10.2.min.js"></script>-->
        <!--        <script src="/static/js/bootstrap.min.js"></script>-->
        <!--        <script src="/static/js/jquery-ui-1.9.2.custom.min.js"></script>-->
        <!--        <script src="/static/js/clipboard.js"></script>-->
        <!--        <script src="/static/js/ZH_Utils.js"></script>-->
        <script>
            eval(loadJs("static/js/ZH_Utils.js"));
            eval(loadJs("static/js/bootstrap.min.js"));
            eval(loadJs("static/js/jquery-ui-1.9.2.custom.min.js"));
            eval(loadJs("static/js/clipboard.js"));
            eval(loadJs("static/js/mymd5.js"));
        </script>
    </div>
</head>
<body>
<!--消息提示框-->
<div id="com_alert" th:if="${msg}!=null">
    <div th:if="${#strings.startsWith(${msg.code}+'','2')}" class="alert alert-success fade in">
        <button type="button" class="close close-sm" data-dismiss="alert">
            <i class="fa fa-times"></i>
        </button>
        <label style="color: green" th:utext="${msg.message}"></label>
    </div>
    <div th:if="${#strings.startsWith(${msg.code}+'','1')}" class="alert alert-info fade in">
        <button type="button" class="close close-sm" data-dismiss="alert">
            <i class="fa fa-times"></i>
        </button>
        <label th:utext="${msg.message}"></label>
    </div>
    <div th:if="${#strings.startsWith(${msg.code}+'','5')}" class="alert alert-danger fade in">
        <button type="button" class="close close-sm" data-dismiss="alert">
            <i class="fa fa-times"></i>
        </button>
        <label style="color: red" th:utext="${msg.message}"></label>
    </div>
    <div th:if="${#strings.startsWith(${msg.code}+'','4')}" class="alert alert-warning fade in">
        <button type="button" class="close close-sm" data-dismiss="alert">
            <i class="fa fa-times"></i>
        </button>
        <label style="color: orange" th:utext="${msg.message}"></label>
    </div>
</div>
<div id="com_captcah_dialog">
    <!-- 设置验证码Modal -->
    <div class="modal fade" id="captcah_model" role="dialog" tabindex="-1" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">人机验证</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form" onsubmit="return false;">
                        <div class="form-group new-email">
                            <label class="col-md-2 control-label">验证码:</label>
                            <div class="col-md-7">
                                <img
                                     onclick="getCaptcha()"
                                     alt="加载失败,请刷新页面重试"
                                     id="img-code">
                                <a onclick="getCaptcha()">换一张</a></label>
                                <p style="margin-top: 8px;font-size: 10px" id="img-code-tips">
                                    根据动图的画面拼凑出完整验证码，并计算验证码的结果</p>
                            </div>
                        </div>
                        <div class="form-group new-email">
                            <label class="col-lg-2 control-label">结果:</label>
                            <div class="col-lg-4">
                                <input type="text" class="form-control" id="code" placeholder="请输入验证码结果" required>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary ver_code">确定</button>
                    <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                </div>
            </div>
        </div>
    </div>
    <script>
        var captcha_callback;

        function captcha_model_show(callback) {
            $('#captcah_model').modal('show');
            captcha_callback = callback;
            // console.log(captcha_callback)
        }

        $('.ver_code').click(function () {
            var code = $("#code").val();
            if (code && code.length > 0) {
                captcha_checking(code);
            } else {
                alert("请输入验证码！")
            }
        });

        function captcha_checking(code,isclear=false) {
            $.ajax({
                url: ZH_URL.captcha_checking,
                type: "post",
                dataType: "json",
                data: {
                    code: code,
                    isClear: isclear
                },
                success: function (d) {
                    if (d.code == 200) {
                        $('#captcah_model').modal('hide');
                        let fun=new excul(captcha_callback);
                        fun.func;
                    } else {
                        alert(d.title + '\n' + d.message);
                        getCaptcha();
                        console.warn(d);
                    }
                },
                error: function (e) {
                    ajax_error(e);
                }
            });
        }

        function getCaptcha() {
            $("#code").val(null);
            $("#img-code").attr("src", "");
            $.ajax({
                url: ZH_URL.captcha_getBase64 + '?t=' + new Date().getTime(),
                type: "get",
                success: function (d) {
                    if (d.code == 200) {
                        $("#img-code").attr("src", d.obj);
                        $("#img-code-tips").text(d.message);
                    } else {
                        alert(d.title + '\n' + d.message);
                        console.warn(d);
                    }
                },
                error: function (e) {
                    ajax_error(e);
                }
            });
        }

        $('#captcah_model').on('show.bs.modal', function () {
            getCaptcha();
        })
        $('#captcah_model').on('hide.bs.modal', function () {
        })

        function excul(methodName) {
            this.func = function() {};
            try {
                this.func = eval(methodName);
            } catch (e) {
                console.error("方法执行",e)
                alert("找不到" + methodName + "这个方法");
            }
        }
        function checkCoookie() {
            hideModel();
            if (getCookie('zhangheng0805_cid').length <= 0)
                setCookie('zhangheng0805_cid', window.localStorage.getItem('zhangheng0805_cid'));
            if (getCookie('zhangheng0805_sid').length <= 0)
                setCookie('zhangheng0805_sid', window.localStorage.getItem('zhangheng0805_sid'));
        }
    </script>
    <!-- modal -->
</div>
</body>
</html>